<template>
  <div>
    <ul>
      <!-- <li><a href="#/contacts/allcontacts">All contacts</a></li>
      <li><a href="#/contacts/alice">Alice</a></li>
      <li><a href="#/contacts/bob">Bob</a></li> -->
      <li><router-link to='/contacts/allcontacts'>All contacts</router-link></li>
      <li><router-link to='/contacts/alice'>Alice</router-link></li>
      <li><router-link to='/contacts/bob'>Bob</router-link></li>
    </ul>
    <button @click="ClickFn">随机显示</button>
    <div>
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: ["Allcontacts", "Alice", "Bob"],
      PathName: "",
    };
  },
  methods: {
    ClickFn() {
      this.PathName = Math.floor(Math.random() * this.arr.length);
    //   console.log(this.arr[this.PathName]);
      this.$router.push({
        name: `${this.arr[this.PathName]}`,
      });
    },
  },
};
</script>

<style>
</style>